package com.atguigu.lease.admin.controller.apartment;

import com.atguigu.lease.admin.service.LeaseTermService;
import com.atguigu.lease.model.bean.LeaseTerm;
import com.atguigu.lease.model.result.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "租期管理模块")
@RestController
@RequestMapping("/admin/term")
public class LeaseTermController {
    @Autowired
    private LeaseTermService leaseTermService;

    @Operation(summary = "1、查询全部租期列表")
    @GetMapping("list")
    public Response<List<LeaseTerm>> list(){
        return Response.ok(leaseTermService.list());
    }
    @Operation(summary = "2、保存或更新租期信息")
    @PostMapping("saveOrUpdate")
    public Response saveOrUpdate(@RequestBody LeaseTerm leaseTerm){
        leaseTermService.saveOrUpdate(leaseTerm);
        return Response.ok(null);
    }
    @Operation(summary = "3、根据id删除租期")
    @DeleteMapping("deleteById")
    public Response deleteById(@RequestParam("id")Long id){
        leaseTermService.removeById(id);
        return Response.ok(null);
    }
}
